which respects the shell precedence of command extensions; thus more.com is listed instead of more.exe, should both exist in the same directory. Likewise, .exe files have precedence over .cmd files, and .cmd files over .bat files. A command with a dot in its name has precedence over any default extension; for example, list.old is found before list.old.exe.
The -a option causes which to list all matching commands in the path, not just the one which would be executed. The -d and -l options alter the nature of the search; when -d is specified, which searches directories in the DPATH for data files, and when -l is specified, it searches through the LIBPATH for dynamic link libraries (.DLLs). The -d and -l options are mutually exclusive, and in both cases the current directory is searched only if ``.'' is listed in the appropriate path.
The output might look something like the following:
To locate all copies of the emx.dll dynamic link library (the first one listed is the one which will be used by the operating system):
To find two of the IBM Redbooks (.inf format):
MS-DOS 5.0 and 6.0 DOSKEY aliases (``macros'') are not yet detected, because there's no good way to do so without writing a temporary file.
There is no reasonable way to determine the LIBPATH in a foolproof manner; it does not have a corresponding environment variable or system call. which looks in the config.sys system file for LIBPATH, but this can fail if the LIBPATH line has been edited since the system was last booted. In addition, under OS/2 1.x there is no way to determine the boot drive, so which may fail even to find the proper config.sys. The 16-bit (or bound) executable first checks for \config.sys on the current drive and then on drive c:, but this will fail if, for example, the system was booted from floppy drive a: and the current drive is c:. The 32-bit executable can determine the boot drive but is still susceptible to editing changes and the possible removal of the boot floppy.
The list of ``proper'' extensions for use with DPATH is somewhat hazy; the following are presently used: .boo, .dat, .hlp, .inf, .ini, .msg and .ndx.